package com.wu.shop.module.classify.frame.view

import androidx.recyclerview.widget.LinearLayoutManager
import com.wkq.base.frame.mosby.delegate.MvpView
import com.wu.common.util.StatusBarUtil
import com.wu.shop.module.classify.frame.model.ClassifyGoodsTypeInfo
import com.wu.shop.module.classify.frame.model.ClassifyTagInfo
import com.wu.shop.module.classify.frame.model.ClassifyTypeInfo
import com.wu.shop.module.classify.ui.adapter.ClassifyTagAdapter
import com.wu.shop.module.classify.ui.adapter.GoodsTypeAdapter
import com.wu.shop.module.classify.ui.fragment.ClassifyFragment

class ClassifyView(fragment: ClassifyFragment) : MvpView {
    var imgUrl = "https://img0.baidu.com/it/u=3101694723,748884042&fm=26&fmt=auto&gp=0.jpg"
    var goodsList = ArrayList<ClassifyGoodsTypeInfo>()
    var typeList = ArrayList<ClassifyTypeInfo>()
    var mFragment = fragment
    private fun initTop() {
        var hight = StatusBarUtil.getStatusBarHeight(mFragment.activity);
        mFragment.binding.tvTitle.setPadding(0, hight + 20, 0, 40)
    }

    fun initView() {
        initTop()
        initContent()
    }

    private fun initContent() {
        mFragment.binding.rvTag.layoutManager = LinearLayoutManager(mFragment.activity)
        mFragment.binding.rvTagContent.layoutManager = LinearLayoutManager(mFragment.activity)
        var tagAdapter = ClassifyTagAdapter(mFragment.activity!!)
        mFragment.binding.rvTag.adapter = tagAdapter
        tagAdapter.addItem(ClassifyTagInfo("洗衣机", 0))
        tagAdapter.addItem(ClassifyTagInfo("衣服", 0))
        tagAdapter.addItem(ClassifyTagInfo("小型洗衣机以及大型冰箱设备你说这嗯么样", 0))
        tagAdapter.addItem(ClassifyTagInfo("电视机", 0))
        tagAdapter.addItem(ClassifyTagInfo("智能设备", 0))

//
        var goodsTypeInfo = ClassifyGoodsTypeInfo("这是个非常长的标题测试展示的问题", 1, imgUrl)

        goodsList.add(goodsTypeInfo)
        goodsList.add(goodsTypeInfo)
        goodsList.add(goodsTypeInfo)
        goodsList.add(goodsTypeInfo)
        goodsList.add(goodsTypeInfo)
        goodsList.add(goodsTypeInfo)
        goodsList.add(goodsTypeInfo)
        goodsList.add(goodsTypeInfo)
        goodsList.add(goodsTypeInfo)
        goodsList.add(goodsTypeInfo)

        for (index in 1..5) {
            var goodsInfo = ClassifyTypeInfo("这是标题:" + index, goodsList)
            typeList.add(goodsInfo)
        }


        var classifyContentAdapter = GoodsTypeAdapter(mFragment.activity!!)
        mFragment.binding.rvTagContent.adapter = classifyContentAdapter
        classifyContentAdapter.addItems(typeList)


    }


}
